home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / PfTypLs.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  5.8 KB  |  213 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PfTypLs.cpp
  3.  
  4.     Contains:    Implementation of class ODPlatformTypeList.
  5.  
  6.     Owned by:    Craig Carper
  7.  
  8.     Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     5/24/96    jpa        1246074: SOM_CATCH --> SOM_TRY..SOM_ENDTRY
  13.  
  14.     To Do:
  15.     In Progress:
  16.         
  17. */
  18.  
  19. #define VARIABLE_MACROS
  20.  
  21. #define ODPlatformTypeList_Class_Source
  22. #include <PfTypLs.xih>
  23.  
  24. #ifndef SOM_ODPlatformTypeListIterator_xh
  25. #include <PfTLItr.xh>
  26. #endif
  27.  
  28. #ifndef SOM_ODObject_xh
  29. #include <ODObject.xh>
  30. #endif
  31.  
  32. #ifndef _ORDCOLL_
  33. #include <OrdColl.h>
  34. #endif
  35.  
  36. #ifndef _EXCEPT_
  37. #include <Except.h>
  38. #endif
  39.  
  40. #pragma segment ODPlatformTypeList
  41.  
  42. //==============================================================================
  43. // Class ODPlatformTypeList
  44. //==============================================================================
  45.  
  46. //------------------------------------------------------------------------------
  47. // ODPlatformTypeList: somUninit
  48. //------------------------------------------------------------------------------
  49.  
  50. SOM_Scope void  SOMLINK ODPlatformTypeListsomUninit(ODPlatformTypeList *somSelf)
  51. {
  52.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  53.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","somUninit");
  54.  
  55.     delete _fList;
  56.  
  57.     parent_somUninit(somSelf);
  58. }
  59.  
  60. //------------------------------------------------------------------------------
  61. // ODPlatformTypeList: InitPlatformTypeList
  62. //------------------------------------------------------------------------------
  63.  
  64. SOM_Scope void  SOMLINK ODPlatformTypeListInitPlatformTypeList(ODPlatformTypeList *somSelf, Environment *ev,
  65.         ODPlatformTypeList* typeList)
  66. {
  67.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  68.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","InitPlatformTypeList");
  69.  
  70.     ODPlatformTypeListIterator* iter = kODNULL;
  71.     ODVolatile(iter);
  72.  
  73.     SOM_TRY
  74.  
  75.         /* Moved from somInit. SOM itself sets fields to zero
  76.         _fList = kODNULL;
  77.         */
  78.         somSelf->InitObject(ev);
  79.     
  80.         _fList = new OrderedCollection;
  81.         
  82.         if ( typeList != (ODPlatformTypeList*) kODNULL )
  83.         {
  84.             iter = typeList->CreatePlatformTypeListIterator(ev);
  85.             
  86.             for (ODPlatformType type = iter->First(ev);
  87.                  iter->IsNotComplete(ev);
  88.                  type = iter->Next(ev))
  89.             {
  90.                 somSelf->AddLast(ev,type);
  91.             }
  92.         }
  93.  
  94.     SOM_CATCH_ALL
  95.  
  96.         ODDeleteObject(_fList);
  97.  
  98.     SOM_ENDTRY
  99.     
  100.     ODDeleteObject(iter);
  101. }
  102.  
  103. //------------------------------------------------------------------------------
  104. // ODPlatformTypeList: AddLast
  105. //------------------------------------------------------------------------------
  106.  
  107. SOM_Scope void  SOMLINK ODPlatformTypeListAddLast(ODPlatformTypeList *somSelf, Environment *ev,
  108.         ODPlatformType type)
  109. {
  110.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  111.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","AddLast");
  112.  
  113.     SOM_TRY
  114.  
  115.     if ( somSelf->Contains(ev,type) == kODFalse )
  116.         _fList->AddLast((ElementType)type);
  117.  
  118.     SOM_CATCH_ALL
  119.     SOM_ENDTRY
  120. }
  121.  
  122. //------------------------------------------------------------------------------
  123. // ODPlatformTypeList: Remove
  124. //------------------------------------------------------------------------------
  125.  
  126. SOM_Scope void  SOMLINK ODPlatformTypeListRemove(ODPlatformTypeList *somSelf, Environment *ev,
  127.         ODPlatformType type)
  128. {
  129.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  130.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","Remove");
  131.  
  132.     SOM_TRY
  133.  
  134.     if ( somSelf->Contains(ev,type) )
  135.         _fList->Remove((ElementType)type);
  136.  
  137.     SOM_CATCH_ALL
  138.     SOM_ENDTRY
  139. }
  140.  
  141. //------------------------------------------------------------------------------
  142. // ODPlatformTypeList: Contains
  143. //------------------------------------------------------------------------------
  144.  
  145. SOM_Scope ODBoolean  SOMLINK ODPlatformTypeListContains(ODPlatformTypeList *somSelf, Environment *ev,
  146.         ODPlatformType type)
  147. {
  148.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  149.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","Contains");
  150.  
  151.     SOM_TRY
  152.  
  153.     return _fList->Contains((ElementType)type);
  154.  
  155.     SOM_CATCH_ALL
  156.     SOM_ENDTRY
  157.     return kODFalse;
  158. }
  159.  
  160. //------------------------------------------------------------------------------
  161. // ODPlatformTypeList: Count
  162. //------------------------------------------------------------------------------
  163.  
  164. SOM_Scope ODULong  SOMLINK ODPlatformTypeListCount(ODPlatformTypeList *somSelf, Environment *ev)
  165. {
  166.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  167.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","Count");
  168.  
  169.     SOM_TRY
  170.  
  171.     return _fList->Count();
  172.  
  173.     SOM_CATCH_ALL
  174.     SOM_ENDTRY
  175.     return 0;
  176. }
  177.  
  178. //------------------------------------------------------------------------------
  179. // ODPlatformTypeList: CreatePlatformTypeListIterator
  180. //------------------------------------------------------------------------------
  181.  
  182. SOM_Scope ODPlatformTypeListIterator*  SOMLINK ODPlatformTypeListCreatePlatformTypeListIterator(ODPlatformTypeList *somSelf, Environment *ev)
  183. {
  184.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  185.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","CreatePlatformTypeListIterator");
  186.  
  187.     SOM_TRY
  188.  
  189.     ODPlatformTypeListIterator* iter = new ODPlatformTypeListIterator;
  190.     if (iter == kODNULL)
  191.         ODSetSOMException(ev, kODErrOutOfMemory);
  192.     else
  193.         iter->InitPlatformTypeListIterator(ev, somSelf);
  194.     
  195.     return iter;
  196.  
  197.     SOM_CATCH_ALL
  198.     SOM_ENDTRY
  199.     return (ODPlatformTypeListIterator*) kODNULL;
  200. }
  201.  
  202. //------------------------------------------------------------------------------
  203. // ODPlatformTypeList: GetImplementation
  204. //------------------------------------------------------------------------------
  205.  
  206. SOM_Scope OrderedCollection*  SOMLINK ODPlatformTypeListGetImplementation(ODPlatformTypeList *somSelf, Environment *ev)
  207. {
  208.     ODPlatformTypeListData *somThis = ODPlatformTypeListGetData(somSelf);
  209.     ODPlatformTypeListMethodDebug("ODPlatformTypeList","GetImplementation");
  210.  
  211.     return _fList;
  212. }
  213.